﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GRC_TPE_WebApp.Controller;

namespace GRC_TPE_WebApp.View.Private.User
{
    public partial class AddUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //Permet d'ajouter un utilisateur après le clic sur le bouton "addUserButton" sur la page "AddUser.aspx"
        protected void addUserButton_Click(object sender, EventArgs e)
        {
            string ret = UserController.AddUser(this.addUserLastName.Text, this.addUserFirstName.Text, this.addUserUsername.Text, this.addUserPassword.Text, this.addUserType.Text);
            if (ret == "No error")
            {
                this.addUserErrorMessage.ForeColor = System.Drawing.Color.DarkGreen;
                this.addUserErrorMessage.Text = "Utilisateur ajouté avec succès";
                this.addUserFirstName.Text = "";
                this.addUserLastName.Text = "";
                this.addUserPassword.Text = "";
                this.addUserUsername.Text = "";
                this.addUserConfirmPassword.Text = "";
                this.addUserType.SelectedIndex = 0;
            }
            else
            {
                this.addUserErrorMessage.ForeColor = System.Drawing.Color.DarkRed;
                this.addUserErrorMessage.Text = ret;
            }
        }
    }
}